class DebugUtils extends BaseClass {
    private _isOpen: boolean;
    private _startTimes: any;
    private _threshold: number;

    public constructor() {
        super();
        this._isOpen = true;
        this._startTimes = {};
        this._threshold = 3
    }

    public setThreshold(value: number): void {
        this._threshold = value;
    }
    public setOpen(flag: boolean): void {
        this._isOpen = flag;
    }

    public get isDebug(): boolean {
        return this._isOpen;
    }

    public start(key: string): void {
        if (!this._isOpen) {
            return;
        }

        this._startTimes[key] = egret.getTimer();
    }

    public stop(key): number {
        if (!this._isOpen) {
            return 0;
        }

        if (!this._startTimes[key]) {
            return 0;
        }

        var cha: number = egret.getTimer() - this._startTimes[key];
        if (cha > this._threshold) {
            console.debug(key + ": " + cha);
        }
        return cha;
    }
}